<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="/style/bootstrap.css" />
</head>
<body>
	<form action="#">
		<input type="button" id="btn" value="ajax测试">
	</form>

	<script type="text/javascript">
		var xmlhttp;
		if (window.XMLHttpRequest) {
			xmlhttp = new XMLHttpRequest();
		}
		document.querySelector("#btn").onclick = function() {
		 xmlhttp.open("GET","/TestServlet",true);
		 xmlhttp.send();
		 } 
		 //响应回调
		 xmlhttp.onreadystatechange=function()
		  {
		   if (xmlhttp.readyState==4 && xmlhttp.status==200)
		    {
			    alert(xmlhttp.responseText);
		    //document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
		    }
		  }
		 
		/*  xmlhttp.open("GET","/TestServlet",true);
		 xmlhttp.send(); */
	</script>
</body>
</html>